package com.hzw.saas.api.product.enums;

import java.util.Objects;

/**
 * <p>
 * 订单类型
 * </p>
 *
 * @author sonam
 * @since 2021/1/25 18:06
 */
public enum OrderType {

    ITEM(1, "购买订单"),
    BALANCE(2, "充值订单");

    private final String text;
    private final Integer value;

    OrderType(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public Integer value() {
        return value;
    }

    public String text() {
        return text;
    }

    public static String text(Integer value) {
        for (OrderType orderType : OrderType.values()) {
            if (Objects.equals(orderType.value, value)) {
                return orderType.text;
            }
        }
        return null;
    }

    public static OrderType instance(Integer value) {
        for (OrderType orderType : OrderType.values()) {
            if (Objects.equals(orderType.value, value)) {
                return orderType;
            }
        }
        return null;
    }
}
